#ifndef __IPOQUE_LINUX_COMPAT_H__
#define __IPOQUE_LINUX_COMPAT_H__

#ifndef LITTLE_ENDIAN
#define LITTLE_ENDIAN (1)
#endif

//Mac头部，总长度14字节
struct EthHeader 
{
	unsigned char dstMac[6]; //目标mac地址
	unsigned char srcMac[6]; //源mac地址
	unsigned short ethType; //以太网类型
};

//IP头部，总长度20字节
struct IpHeader 
{
#if LITTLE_ENDIAN
	unsigned char ihl:4, version:4;   //首部长度 版本
#else
	unsigned char version:4, ihl:4; //版本 首部长度
#endif
	unsigned char tos;   //服务类型
	unsigned short totLen; //总长度
	unsigned short id;    //标志
	unsigned short fragOff; //分片偏移
	unsigned char ttl;   //生存时间
	unsigned char protocol; //协议
	unsigned short checkSum; //检验和
	unsigned int srcIP; //源IP地址
	unsigned int  dstIP; //目的IP地址
};

//TCP头部，总长度20字节
struct TcpHeader
{
	unsigned short srcPort;   //源端口号
	unsigned short dstPort;   //目的端口号
	unsigned int seqNum;    //序列号
	unsigned int ackNum;    //确认号
#if LITTLE_ENDIAN
	unsigned char res1:4, thl:4; //保留6位中的4位首部长度 tcp头部长度
	unsigned char fin:1, syn:1, rst:1, psh:1, ack:1, urg:1, ece:1, cwr:1; 
#else
	unsigned char thl:4, res1:4;    //tcp头部长度 保留6位中的4位首部长度
	unsigned char cwr:1, ece:1, urg:1, ack:1, psh:1, rst:1, syn:1, fin:1;
#endif
	unsigned short windowSize;   //16位窗口大小
	unsigned short checkSum;   //16位TCP检验和
	unsigned short urgentPoint;    //16为紧急指针
};

//UDP头部，总长度8字节
struct UdpHeader
{
	unsigned short srcPort; //远端口号
	unsigned short dstPort; //目的端口号
	unsigned short uhl;   //udp头部长度
	unsigned short checkSum; //16位udp检验和
};

//ICMP头部，总长度4字节
struct IcmpHeader
{
	unsigned char icmpType;   //类型
	unsigned char code;    //代码
	unsigned short checkSum;   //16位检验和
}; 

#endif
